var reg = new ActiveXObject("WScript.Shell");var inv;var defaultbackground = "";var lastback = "";var BackgroundChangeEvent;var lastsec = 0;function getGlobalBack(){return reg.RegRead(regPath);}function setGlobalBack(BackID){reg.RegWrite(regPath,BackID);}function saveGlobalBackgroundSettings(ValueId,CheckboxId){try{System.Gadget.Settings.write("globalback", document.getElementById(CheckboxId).checked);if (document.getElementById(CheckboxId).checked)setGlobalBack(document.getElementById(ValueId).value);}catch(ex){}}function loadGlobalBackgroundSettings(ValueId,CheckboxId){try{document.getElementById(CheckboxId).checked = System.Gadget.Settings.read("globalback");if (document.getElementById(CheckboxId).checked)document.getElementById(ValueId).value = getGlobalBack();}catch(ex){}}function startGlobalBackground(onBackgroundChange){try{BackgroundChangeEvent = onBackgroundChange;if (inv) clearInterval(inv);if (System.Gadget.Settings.read("globalback"))inv = setInterval(timerEvent,200);}catch(ex){}}function timerEvent(){try{var date = new Date();var secs = date.getSeconds();if ((secs % 2) == 0){if (lastsec != secs){lastsec = secs;currentback = getGlobalBack();if (currentback != lastback){if ( typeof(BackgroundChangeEvent) == "function" ) BackgroundChangeEvent(currentback);}lastback = currentback;}}}catch(ex){debugLog("timerEvent: "+ex.name+" - "+ex.message);}}